var UId = getParameter("UId");
var now = new Date();
$(function() {
	charts(now);
});
function charts(now) {
	var urlStr = serverPath + "/app/doctor/diabetes/pressureView.do";
	var jsonStr = '{method:"showPressureChart",UId:"' + UId + '",befdate:"'
			+ getLastDay(now, 3).format("yyyy-MM-dd") + '",aftdate:"'
			+ getNextDay(now, 3).format("yyyy-MM-dd") + '",day:"7"}';
	UseAjax(urlStr, jsonStr, document.cookie, rt, '1');
}
function rt(data) {
	var systolics = new Array();
	var diastolics = new Array();
	var wi = data.records;
	if(wi.length > 0){
	for (var int = 0; int < wi.length; int++) {
		var datas = wi[int].value.split("/");
		systolics[int] = [
				Date.UTC(wi[int].dates.substring(0, 4), wi[int].dates.substring(
						5, 7) - 1, wi[int].dates.substring(8, 10), wi[int].dates
						.substring(11, 13)), Number(datas[0]) ];
		diastolics[int] = [
		  				Date.UTC(wi[int].dates.substring(0, 4), wi[int].dates.substring(
		  						5, 7) - 1, wi[int].dates.substring(8, 10), wi[int].dates
		  						.substring(11, 13)), Number(datas[1]) ];
		  	
	}}
	$('#container').highcharts(
			{

				title : {
					text : ''
				},
				subtitle : {
					text : getLastDay(now, 3).format("yyyy-MM-dd")+" 到 "+getNextDay(now, 3).format("yyyy-MM-dd")
				},
				colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
				xAxis : {
					 type : 'datetime',
					  dateTimeLabelFormats : {
						    second : '%H:%M:%S',
						    minute : '%H:%M',
						    hour : '%H:%M',
						    day : '%m-%d',
						    week : '%m-%d',
						    month : '%m',
						    year : '%Y'
						  }, 
					min : Date.UTC(now.getFullYear(), now.getMonth(), now
									.getDate() - 3),
					max : Date.UTC(now.getFullYear(), now.getMonth(), now
									.getDate() + 3),
					maxPadding : 5,
					gridLineWidth : 1,
					gridLineDashStyle : 'Dash',// 样式 虚线

				},
				yAxis : {
					min : 0, // 固定列最小值
					max : 250,
					title : {
						align: 'high',
		                offset: 10,
		                text: 'mmhg',
		                rotation: 0,
		                y: -10
					},labels : {
						formatter : function() {
							return "" + this.value;
						}
					} 
					,
				},
				tooltip : {
					formatter : function() {
					}
				},
				plotOptions : {
					line : {
						dataLabels : {
							enabled : true
						},
						enableMouseTracking : false
					}
				},
				credits : {
					enabled : false
				},
				legend : {
					enabled : false
				},
				series : [ {
					pointPadding : 0,// 数据点之间的距离值
					groupPadding : 0,// 分组之间的距离值
					name : null,
					 name: 'systolic',
					data : systolics
				}, {
					name: 'diastolic',
					data : diastolics
				} ]
			});
}

$(function() {
	// swipe 的dome
	$("#container").swipe(
			{
				swipeLeft : function(event, direction, distance, duration,
						fingerCount) {
					now = getNextDay(now, 7);
					charts( now);
				},
				swipeRight : function(event, direction, distance, duration,
						fingerCount) {
					now = getLastDay(now, 7);
					charts(now);
				},
			});

});
